'''
Company: TWL
Author: xue jian
Email: xuejian@kanzhun.com
Date: 2020-11-16 19:56:51
'''
#
# @lc app=leetcode.cn id=1441 lang=python3
#
# [1441] 用栈操作构建数组
#

# @lc code=start
from typing import List
class Solution:
    def buildArray(self, target: List[int], n: int) -> List[str]:
        ind=0
        i=1
        ans = []
        while ind<len(target) and i<=n:
            if i==target[ind]:
                ans.append('Push')
                ind+=1
            elif i<target[ind]:
                ans.extend(['Push', 'Pop'])
            else:
                pass
            i+=1
        return ans
# @lc code=end

